<?php

require_once('db/db.php');

$db=new DB;

function check($name){
	if(isset($_REQUEST[$name])){
		return $_REQUEST[$name];
	}
	else{
		die();
	}
}

$id=intval(check('id'));
$name=check('name');
$category=check('category');


$sql = "update `product` set `name`='$name',`category`='$category' where `id`=$id";

echo $sql;
if(!$db->query($sql)){
	die();
}

echo json_encode(array(
	'id' => $id,
	'name' => $name,
	'category' => $category,
));

?>
